package test.service;

import org.json.JSONObject;

import test.testcase.jenkins;
import test.testcase.dao.JenkinsDao;
import test.utils.JsonResult;

public class ServiceJenkins {
	
	public static jenkins getJenkinsInfo(String projectid) {
		jenkins jenkins = new jenkins();
		jenkins.setProjectid(projectid);
		JsonResult result = JenkinsDao.getJenkinsInfo(projectid);
		JSONObject object = result.read("data[0]").toJsonObject();
		if (object == null) {
			return null;
		}
		jenkins.setFolder(object.getString("folder"));
		jenkins.setHost(object.getString("host"));
		jenkins.setJobName(object.getString("jobname"));
		jenkins.setUsername(object.getString("username"));
		jenkins.setToken(object.getString("token"));
		return jenkins;
	}

}
